<?php

namespace app\api\validate;

use think\Validate;

class GoodsClassScene extends Validate
{
    protected $rule = [
        'id' => ["require","number"],
        'name' => ['require','length'=>'1,10','unique:goods_class'],
        "data_state" => ['number','require'],
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'name.require' => '产品分类名不能为空',
        'name.length' => '产品分类名长度为1-10个字符',
        'name.unique' => '产品分类名不能相同',
        'id.require' => '产品分类ID不能为空',
        'id.number' => '产品分类ID只能为数值',
        'data_state.number' =>'数据状态必须为数值',
        'data_state.require' =>'未设置状态',
    ];

    protected $scene = [
        'add'  =>  ['name'],
        'update'  =>  ['id','name'],
        'update_state' => ['id',"data_state"]
    ];
}